// createRouter: 方法 生成路由实例对象的
// createWebHashHistory: 方法 创建hash模式的路由对象
import { createRouter, createWebHashHistory } from 'vue-router'
import Layout from '@/views/Layout'
import Login from '@/views/Login'
import Category from '@/views/Category'
import Home from '@/views/Home'
import Good from '@/views/Good'
// 这里定义路径和组件对应的关系
const routes = [
  {
    path: '/login',
    component: Login
  },
  {
    path: '/',
    component: Layout,
    children: [
      {
        path: '', // 如果二级路由path为空将作为默认渲染的路由
        component: Home
      },
      {
        name: 'category',
        path: 'category/:id',
        component: Category
      },
      {
        path: 'good/:id',
        component: Good
      }
    ]
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router
